package com.netease.a.b;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Random;
import org.apache.http.Header;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EncodingUtils;

public class h extends AbstractHttpEntity
{
  public static final String a = "http.method.multipart.boundary";
  private static final String c = "multipart/form-data";
  private static byte[] d = EncodingUtils.getAsciiBytes("-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
  protected a[] b;
  private byte[] e;
  private HttpParams f;
  private boolean g = false;

  public h(a[] paramArrayOfa)
  {
    setContentType("multipart/form-data");
    if (paramArrayOfa == null)
      throw new IllegalArgumentException("parts cannot be null");
    this.b = paramArrayOfa;
    this.f = null;
  }

  public h(a[] paramArrayOfa, HttpParams paramHttpParams)
  {
    if (paramArrayOfa == null)
      throw new IllegalArgumentException("parts cannot be null");
    if (paramHttpParams == null)
      throw new IllegalArgumentException("params cannot be null");
    this.b = paramArrayOfa;
    this.f = paramHttpParams;
  }

  public static byte[] a()
  {
    Random localRandom = new Random();
    byte[] arrayOfByte = new byte[30 + localRandom.nextInt(11)];
    for (int i = 0; i < arrayOfByte.length; i++)
      arrayOfByte[i] = d[localRandom.nextInt(d.length)];
    return arrayOfByte;
  }

  protected byte[] b()
  {
    String str;
    if (this.e == null)
    {
      str = null;
      if (this.f != null)
        str = (String)this.f.getParameter("http.method.multipart.boundary");
      if (str == null)
        break label48;
    }
    label48: for (this.e = EncodingUtils.getAsciiBytes(str); ; this.e = a())
      return this.e;
  }

  public InputStream getContent()
  {
    if ((!isRepeatable()) && (this.g))
      throw new IllegalStateException("Content has been consumed");
    this.g = true;
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    a.a(localByteArrayOutputStream, this.b, this.e);
    return new ByteArrayInputStream(localByteArrayOutputStream.toByteArray());
  }

  public long getContentLength()
  {
    try
    {
      long l2 = a.a(this.b, b());
      l1 = l2;
      return l1;
    }
    catch (Exception localException)
    {
      while (true)
        long l1 = 0L;
    }
  }

  public Header getContentType()
  {
    StringBuffer localStringBuffer = new StringBuffer("multipart/form-data");
    localStringBuffer.append("; boundary=");
    localStringBuffer.append(EncodingUtils.getAsciiString(b()));
    return new BasicHeader("Content-Type", localStringBuffer.toString());
  }

  public boolean isRepeatable()
  {
    int i = 0;
    int j = 0;
    if (j < this.b.length)
      if (this.b[j].g());
    while (true)
    {
      return i;
      j++;
      break;
      i = 1;
    }
  }

  public boolean isStreaming()
  {
    return false;
  }

  public void writeTo(OutputStream paramOutputStream)
  {
    a.a(paramOutputStream, this.b, b());
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.a.b.h
 * JD-Core Version:    0.6.0
 */